Hệ thống quản lý phòng khám trực tuyến bằng PHP
1 <?php
2 $currDir=dirname(__FILE__);
3 include("$currDir/defaultLang.php");
4 include("$currDir/language.php");
5 include("$currDir/lib.php");
6
7 handle_maintenance();
8
9 // image paths
10 $p=array(
11 'patients' => array(
12 'image' => $Translation['ImageFolder']
13 ),
14 'medical_records' => array(
15 'image_1' => $Translation['ImageFolder'],
16 'image_2' => $Translation['ImageFolder'],
17 'image_3' => $Translation['ImageFolder'],
18 'image_4' => $Translation['ImageFolder'],
19 'image_5' => $Translation['ImageFolder']
20 )
21 );
22
23 if(!count($p)) exit;
24
25 // receive user input
26 $t=$_GET['t']; // table name
27 $f=$_GET['f']; // field name
28 $v=$_GET['v']; // thumbnail view type: 'tv' or 'dv'
29 $i=$_GET['i']; // original image file name
30
31 // validate input
32 if(!in_array($t, array_keys($p))) getImage();
33 if(!in_array($f, array_keys($p[$t]))) getImage();
34 if(!preg_match('/^[a-z0-9_]+\.(gif|png|jpg|jpeg|jpe)$/i', $i, $m)) getImage();
35 if($v!='tv' && $v!='dv') getImage();
36
37 $img=$p[$t][$f].$i;
38 $thumb=str_replace(".$m[1]ffffgggg", "_$v.$m[1]", $img.'ffffgggg');
39
40 // if thumbnail exists and the user is not admin, output it without rebuilding the thumbnail
41 if(getImage($thumb) && !getLoggedAdmin()) exit;
42
43 // otherwise, try to create the thumbnail and output it
44 if(!createThumbnail($img, getThumbnailSpecs($t, $f, $v))) getImage();
45 if(!getImage($thumb)) getImage();
46
47
48 function getImage($img=''){
49 if(!$img){ // default image to return
50 $img='./photo.gif';
51 $exit=TRUE;
52 }
53 $thumbInfo=@getimagesize($img);
54 $fp=@fopen($img, 'rb');
55 if($thumbInfo && $fp){
56 header("Content-type: {$thumbInfo['mime']}");
57 fpassthru($fp);
58 if(!$exit) return TRUE; else exit;
59 }
60
61 if(!$exit) return FALSE; else exit;
62 }